import requests
from lxml import etree
import execjs

'''
1. 完美世界网站RSA加密
2. 给RSAjs文件增加调用函数，创建对象，公钥在网页iframe代码里
'''

url = 'https://passport.wanmei.com/sso/login?service=passport&isiframe=1&location=2f736166652f'
heards = {
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36"
}
page_text = requests.get(url=url, headers=heards).text

tree = etree.HTML(page_text)
key = tree.xpath('//input[@id="e"]/@value')[0]

node = execjs.get()

ctx = node.compile(open('./文件/完美世界RSA.js', encoding='utf-8').read())

funcName = 'getPwd("{}", "{}")'.format("123456", key)

pwd = ctx.eval(funcName)

print(pwd)

